package com.zhangmeng.online.exam.ui.service;

import com.alibaba.fastjson2.JSONObject;
import com.zhangmeng.online.exam.ui.utils.AlertUtils;
import com.zhangmeng.online.exam.ui.utils.ApiUtils;
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
import javafx.scene.control.Alert;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zm
 * @date 2025/4/19 11:43
 * @version: 1.0
 */
public class ExamService {
    public static boolean submitExam(String jsonString) {
        Map<String, Object> map = new HashMap<>();
        map.put("json_data", jsonString);
        String response = HttpUtils.POST(ApiUtils.API_URL + "/exam/saveAnswer", map);
        try {
            JSONObject jsonObject = JSONObject.parseObject(response);
            return jsonObject.getIntValue("code") == 200;
        } catch (Exception e) {
            //throw new RuntimeException(e);
            return false;
        }
    }
}
